﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional

namespace BackOffice.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class InitSecond : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Folders",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    Name = table.Column<string>(type: "text", nullable: true),
                    Description = table.Column<string>(type: "text", nullable: true),
                    ParentId = table.Column<Guid>(type: "uuid", nullable: true),
                    Code = table.Column<string>(type: "text", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
                    CreateBy = table.Column<string>(type: "text", nullable: false),
                    UpdateBy = table.Column<string>(type: "text", nullable: false),
                    RowVersion = table.Column<byte[]>(type: "bytea", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Folders", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Folders_Folders_ParentId",
                        column: x => x.ParentId,
                        principalTable: "Folders",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "Files",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    FileName = table.Column<string>(type: "text", nullable: false),
                    FileSize = table.Column<long>(type: "bigint", nullable: false),
                    FileExtension = table.Column<string>(type: "text", nullable: false),
                    MimeType = table.Column<string>(type: "text", nullable: false),
                    RelativePath = table.Column<string>(type: "text", nullable: false),
                    Description = table.Column<string>(type: "text", nullable: true),
                    FolderId = table.Column<Guid>(type: "uuid", nullable: true),
                    Code = table.Column<string>(type: "text", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
                    CreateBy = table.Column<string>(type: "text", nullable: false),
                    UpdateBy = table.Column<string>(type: "text", nullable: false),
                    RowVersion = table.Column<byte[]>(type: "bytea", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Files", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Files_Folders_FolderId",
                        column: x => x.FolderId,
                        principalTable: "Folders",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "Acls",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    FileId = table.Column<Guid>(type: "uuid", nullable: false),
                    UserId = table.Column<Guid>(type: "uuid", nullable: false),
                    Access = table.Column<int>(type: "integer", nullable: false),
                    Code = table.Column<string>(type: "text", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
                    CreateBy = table.Column<string>(type: "text", nullable: false),
                    UpdateBy = table.Column<string>(type: "text", nullable: false),
                    RowVersion = table.Column<byte[]>(type: "bytea", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Acls", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Acls_Files_FileId",
                        column: x => x.FileId,
                        principalTable: "Files",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "Shares",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    FileId = table.Column<Guid>(type: "uuid", nullable: false),
                    SharedTo = table.Column<Guid>(type: "uuid", nullable: false),
                    ExpireAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    Mode = table.Column<int>(type: "integer", nullable: false),
                    Code = table.Column<string>(type: "text", nullable: true),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
                    CreateBy = table.Column<string>(type: "text", nullable: false),
                    UpdateBy = table.Column<string>(type: "text", nullable: false),
                    RowVersion = table.Column<byte[]>(type: "bytea", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Shares", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Shares_Files_FileId",
                        column: x => x.FileId,
                        principalTable: "Files",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.UpdateData(
                table: "AppMenus",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "AppPermissions",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "AppRolePermissions",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "AppRoles",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "AppSystemSettings",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "AppUserRoles",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "AppUsers",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "LastLoginAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "ArticleTags",
                keyColumn: "Id",
                keyValue: new Guid("66666666-6666-6666-6666-666666666666"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "ArticleTags",
                keyColumn: "Id",
                keyValue: new Guid("77777777-7777-7777-7777-777777777777"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "Articles",
                keyColumn: "Id",
                keyValue: new Guid("22222222-2222-2222-2222-222222222222"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "Articles",
                keyColumn: "Id",
                keyValue: new Guid("33333333-3333-3333-3333-333333333333"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.InsertData(
                table: "Folders",
                columns: new[] { "Id", "Code", "CreateBy", "CreatedAt", "Description", "IsDeleted", "Name", "ParentId", "RowVersion", "UpdateBy", "UpdatedAt" },
                values: new object[] { new Guid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"), null, "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), "系统初始化示例目录", false, "示例文件夹", null, new byte[0], "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "Tags",
                keyColumn: "Id",
                keyValue: new Guid("44444444-4444-4444-4444-444444444444"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.UpdateData(
                table: "Tags",
                keyColumn: "Id",
                keyValue: new Guid("55555555-5555-5555-5555-555555555555"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.InsertData(
                table: "Files",
                columns: new[] { "Id", "Code", "CreateBy", "CreatedAt", "Description", "FileExtension", "FileName", "FileSize", "FolderId", "IsDeleted", "MimeType", "RelativePath", "RowVersion", "UpdateBy", "UpdatedAt" },
                values: new object[,]
                {
                    { new Guid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"), null, "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), "项目说明文档", ".md", "README.md", 1024L, new Guid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"), false, "text/markdown", "uploads/2025/07/README.md", new byte[0], "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) },
                    { new Guid("cccccccc-cccc-cccc-cccc-cccccccccccc"), null, "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), "公司Logo", ".png", "logo.png", 20480L, new Guid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"), false, "image/png", "uploads/2025/07/logo.png", new byte[0], "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) }
                });

            migrationBuilder.InsertData(
                table: "Acls",
                columns: new[] { "Id", "Access", "Code", "CreateBy", "CreatedAt", "FileId", "IsDeleted", "RowVersion", "UpdateBy", "UpdatedAt", "UserId" },
                values: new object[] { new Guid("eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee"), 7, null, "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new Guid("cccccccc-cccc-cccc-cccc-cccccccccccc"), false, new byte[0], "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new Guid("11111111-1111-1111-1111-111111111111") });

            migrationBuilder.InsertData(
                table: "Shares",
                columns: new[] { "Id", "Code", "CreateBy", "CreatedAt", "ExpireAt", "FileId", "IsDeleted", "Mode", "RowVersion", "SharedTo", "UpdateBy", "UpdatedAt" },
                values: new object[] { new Guid("dddddddd-dddd-dddd-dddd-dddddddddddd"), null, "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293), new DateTime(9999, 12, 31, 15, 59, 59, 999, DateTimeKind.Utc).AddTicks(9999), new Guid("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"), false, 1, new byte[0], new Guid("11111111-1111-1111-1111-111111111111"), "system", new DateTime(2025, 7, 29, 8, 21, 43, 997, DateTimeKind.Utc).AddTicks(7293) });

            migrationBuilder.CreateIndex(
                name: "IX_Acls_FileId",
                table: "Acls",
                column: "FileId");

            migrationBuilder.CreateIndex(
                name: "IX_Files_FolderId",
                table: "Files",
                column: "FolderId");

            migrationBuilder.CreateIndex(
                name: "IX_Folders_ParentId",
                table: "Folders",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_Shares_FileId",
                table: "Shares",
                column: "FileId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Acls");

            migrationBuilder.DropTable(
                name: "Shares");

            migrationBuilder.DropTable(
                name: "Files");

            migrationBuilder.DropTable(
                name: "Folders");

            migrationBuilder.UpdateData(
                table: "AppMenus",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "AppPermissions",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "AppRolePermissions",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "AppRoles",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "AppSystemSettings",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "AppUserRoles",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "AppUsers",
                keyColumn: "Id",
                keyValue: new Guid("11111111-1111-1111-1111-111111111111"),
                columns: new[] { "CreatedAt", "LastLoginAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "ArticleTags",
                keyColumn: "Id",
                keyValue: new Guid("66666666-6666-6666-6666-666666666666"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "ArticleTags",
                keyColumn: "Id",
                keyValue: new Guid("77777777-7777-7777-7777-777777777777"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "Articles",
                keyColumn: "Id",
                keyValue: new Guid("22222222-2222-2222-2222-222222222222"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "Articles",
                keyColumn: "Id",
                keyValue: new Guid("33333333-3333-3333-3333-333333333333"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "Tags",
                keyColumn: "Id",
                keyValue: new Guid("44444444-4444-4444-4444-444444444444"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });

            migrationBuilder.UpdateData(
                table: "Tags",
                keyColumn: "Id",
                keyValue: new Guid("55555555-5555-5555-5555-555555555555"),
                columns: new[] { "CreatedAt", "UpdatedAt" },
                values: new object[] { new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301), new DateTime(2025, 7, 29, 7, 16, 15, 204, DateTimeKind.Utc).AddTicks(3301) });
        }
    }
}
